import os
import time
import unittest
from HTMLTestRunner import HTMLTestRunner


def Creat_casae(loader_path,report_path):
    loader = unittest.defaultTestLoader.loadTestsFromName(loader_path)
    filename = time.strftime('%Y%m%d%H%M%S') + '-demo.html'
    filepath = os.path.join(report_path, filename)
    print(filepath)
    with open(filepath, 'wb') as f:
        runner = HTMLTestRunner(
            title='测试报告标题',
            stream=f,
            verbosity=2
        )
        runner.run(loader)


loader_path ='case.test_goods'
report = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '\\report'
case =Creat_casae(loader_path, report)